clear; clc;

% 参数固定
b = 2*pi;
c = 11.5;
a_list = linspace(0, 5, 500);

% 迭代参数
N_transient = 1000;  % 去除初始影响
N_points = 200;      % 记录后续点数

% 初始条件
x0 = 0.4; y0 = 0.8; z0 = 0.6;

% 保存数据
a_vals = [];
x_vals = [];

parfor idx = 1:length(a_list)
    a = a_list(idx);
    x = x0; y = y0; z = z0;
    
    % 先迭代丢弃初始点
    for i = 1:N_transient
        [x, y, z] = SIMM(x, y, z, a, b, c);
    end
    
    % 迭代记录轨迹点
    x_temp = zeros(1, N_points);
    for i = 1:N_points
        [x, y, z] = SIMM(x, y, z, a, b, c);
        x_temp(i) = x;
    end
    
    % 存储
    a_vals = [a_vals, repmat(a, 1, N_points)];
    x_vals = [x_vals, x_temp];
end

% 绘制分岔图
figure;
plot(a_vals, x_vals, '.', 'MarkerSize', 3, 'Color', 'b');
xlabel('a', 'FontSize', 14, 'Interpreter', 'latex');
ylabel('$X_{\max}$', 'FontSize', 14, 'Interpreter', 'latex');
grid on;

